﻿#include "ini_file.h"
#include <QtCore/QtCore>
#include <QFile>
#include <QDebug>

INI_File::INI_File()
{
    m_qstrFileName = QCoreApplication::applicationDirPath() + "/Config.ini";

    qDebug()<<"m_qstrFileName: "<<m_qstrFileName;

    //"Config.ini"配置文件，文件存在则打开，不存在则创建
    m_psetting = new QSettings(m_qstrFileName,QSettings::IniFormat);
    //设置读取的编码格式
    m_psetting->setIniCodec(QTextCodec::codecForName("UTF-8"));
    //m_psetting->beginGroup("company");

}

INI_File::~INI_File()
{
    delete m_psetting;
    m_psetting = NULL;
}

QTextCodec *codec = QTextCodec::codecForName("UTF-8");

void INI_File::SetRememberConfig(QString qstrRemember)
{
    m_psetting->setValue("/Config/RememberConfig",qstrRemember);
}

QString INI_File::GetRememberConfig()
{
    return m_psetting->value("/Config/RememberConfig").toString();
}

void INI_File::SetServerIP(QString qstrIp)
{
    m_psetting->setValue("/Config/ServerIP",qstrIp);
}

QString INI_File::GetServerIP()
{
    return m_psetting->value("/Config/ServerIP").toString();
}

QString INI_File::GetPortLoginUser()
{
    return m_psetting->value("/Config/PortLoginUser").toString();
}

QString INI_File::GetPortPostMesg()
{
    return m_psetting->value("/Config/PortPostMesg").toString();
}

QString INI_File::GetPortPostFile()
{
    return m_psetting->value("/Config/PortPostFile").toString();
}

QString INI_File::GetPortAuthByMac()
{
    return m_psetting->value("/Config/PortAuthByMac").toString();
}

QString INI_File::GetPortAuthByIP()
{
    return m_psetting->value("/Config/PortAuthByIP").toString();
}

QString INI_File::GetPortAuthByDomainUser()
{
    return m_psetting->value("/Config/PortAuthByDomainUser").toString();
}

QString INI_File::GetClientExit()
{
    return m_psetting->value("/Config/ClientExit").toString();
}

QString INI_File::GetSendShareMessage()
{
    return m_psetting->value("/Config/SendShareMessage").toString();
}

QString INI_File::GetJobList()
{
    return m_psetting->value("/Config/JobList").toString();
}

QString INI_File::DeleteJob()
{
    return m_psetting->value("/Config/ServerIP").toString();
}

void INI_File::SetTitleBackgroudColor(QString qstrTitleBackgroudColor)
{
    m_psetting->setValue("/Config/TitleBackgroudColor",qstrTitleBackgroudColor);
}

QString INI_File::GetTitleBackgroudColor()
{
    return m_psetting->value("/Config/TitleBackgroudColor").toString();
}

void INI_File::SetDurationTime(QString qstrDurationTime)
{
    m_psetting->setValue("/Config/DurationTime",qstrDurationTime);
}

QString INI_File::GetDurationTime()
{
    return m_psetting->value("/Config/DurationTime").toString();
}

void INI_File::SetListenPort(QString qstrListenPort)
{
    m_psetting->setValue("/Config/ListenPort",qstrListenPort);
}

QString INI_File::GetListenPort()
{
    return m_psetting->value("/Config/ListenPort").toString();
}

void INI_File::SetMode(int qstrMode)
{
    m_psetting->setValue("/Config/Mode",qstrMode);
}

int INI_File::GetMode()
{
    return m_psetting->value("/Config/Mode").toInt();
}

void INI_File::SetUserName(QString qstrUserName)
{
    m_psetting->setValue("/Config/user",qstrUserName);
}

QString INI_File::GetUserName()
{
    return m_psetting->value("/Config/UserName").toString();
}

void INI_File::SetPassWord(QString qstrPassword)
{
    m_psetting->setValue("/Config/password",qstrPassword);
}

QString INI_File::GetPassWord()
{
    return m_psetting->value("/Config/PassWord").toString();
}

void INI_File::SetMac(QString qstrMac)
{
    m_psetting->setValue("/Config/Mac",qstrMac);
}

QString INI_File::GetMac()
{
    return m_psetting->value("/Config/Mac").toString();
}

void INI_File::SetTerminaltype(QString qstrTerminaltype)
{
    m_psetting->setValue("/Config/terminaltype",qstrTerminaltype);
}

QString INI_File::GetTerminaltype()
{
    return m_psetting->value("/Config/terminaltype").toString();
}

void INI_File::SetPortShared(QString qstrPortShared)
{
    m_psetting->setValue("/Config/PortShared",qstrPortShared);
}

QString INI_File::GetPortShared()
{
    return m_psetting->value("/Config/PortShared").toString();
}

void INI_File::SetDefaultprinter(QString qstrDefaultprinter)
{
    m_psetting->setValue("/Config/defaultprinter",qstrDefaultprinter);
}

QString INI_File::GetDefaultprinter()
{
    return m_psetting->value("/Config/defaultprinter").toString();
}

void INI_File::SetDefaultprinterName(QString qstrDefaultprinterName)
{
    m_psetting->setValue("/Config/defaultprinterName",qstrDefaultprinterName);
}

QString INI_File::GetDefaultprinterName()
{
    return m_psetting->value("/Config/defaultprinterName").toString();
}

void INI_File::SetIsServerMode(QString qstrIsServerMode)
{
    m_psetting->setValue("/Config/IsServerMode",qstrIsServerMode);
}

void INI_File::SetDocPath(QString qstrDocPath)
{
    m_psetting->setValue("/Config/DocPath",qstrDocPath);
}

QString INI_File::GetDocPath()
{
    return m_psetting->value("/Config/DocPath").toString();
}

void INI_File::SetServerNodes(QString qstrServerNodes)
{
    m_psetting->setValue("/Config/ServerNodes",qstrServerNodes);
}

QString INI_File::GetServerNodes()
{
    return m_psetting->value("/Config/ServerNodes").toString();
}

void INI_File::SetTitle(QString qstrTitle)
{
    m_psetting->setValue("/Config/Title",qstrTitle);;
}

QString INI_File::GetTitle()
{
    QString title = m_psetting->value("/Config/Title").toString();
    //QString titleUn = codec->toUnicode(title);
    return title;
}
